<?php

class InstallController extends AuthController
{
    public function init()
    {
        parent::init();
        
        //not allow install twice.
        if($this->module->getHasInstalled())
            $this->redirect('/');
    }
    
    public function actionIndex()
    {
        $this->layout = '//layouts/base';
        $model = Yii::createComponent('AuthInstallForm');
        $model->setModule($this->module);
        
		// collect user input data
		if(isset($_POST['AuthInstallForm']))
		{
			$model->attributes = $_POST['AuthInstallForm'];
            if($model->validate() && $model->save())
                $this->redirect(array('auth/default/index'));    
		}
        
		// display the login form
		$this->render('index',array('model'=>$model));
    }
}